package com.bai.localshop.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 地址簿
 */
@Data
@TableName("address_book")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AddressBook implements Serializable {

    private static final long serialVersionUID = 1L;
    @TableId(type = IdType.AUTO)
    private Long id;

    //用户id
    @NotNull(message = "用户ID不能为空")
    private Long userId;

    //收货人
    @NotBlank(message = "收货人不能为空")
    private String consignee;

    //手机号
    @NotBlank(message = "手机号不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String phone;

    //性别 0-未知 1-男 2-女
    private Integer sex;

    //省级区划编号
    @NotBlank(message = "省份不能为空")
    private String provinceCode;

    //省级名称
    @NotBlank(message = "省份名称不能为空")
    private String provinceName;

    //市级区划编号
    @NotBlank(message = "城市不能为空")
    private String cityCode;

    //市级名称
    @NotBlank(message = "城市名称不能为空")
    private String cityName;

    //区级区划编号
    @NotBlank(message = "区县不能为空")
    private String districtCode;

    //区级名称
    @NotBlank(message = "区县名称不能为空")
    private String districtName;

    //详细地址
    @NotBlank(message = "详细地址不能为空")
    private String detail;

    //标签
    private String label;

    //是否默认 0否 1是
    private Integer isDefault;

    //创建时间
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    //更新时间
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
}